Add option to auto recenter after diff-hl-{next,previous}-hunk#260
Add option to auto recenter after diff-hl-{next,previous}-hunk#260NicholasBHubbard wants to merge 2 commits intodgutov:masterfrom
Conversation
|
Hi! Could this approach be a little problematic? This function is also called from |
|
Thanks for the response! I just looked and found that indeed I came up with a simple solution to just disable |
|
Alternate solution to 3ffc55c: diff --git a/diff-hl.el b/diff-hl.el
index 6b2fa14..0081e5f 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -1082,14 +1082,14 @@ its end position."
(when (and o (= (overlay-start o) (point)))
(throw 'found o)))))))
-(defun diff-hl-next-hunk (&optional backward)
+(defun diff-hl-next-hunk (&optional backward no-recenter)
"Go to the beginning of the next hunk in the current buffer."
(interactive)
(let ((overlay (diff-hl-search-next-hunk backward)))
(unless overlay
(user-error "No further hunks found"))
(goto-char (overlay-start overlay))
- (when diff-hl-next-previous-hunk-auto-recenter
+ (when (and diff-hl-next-previous-hunk-auto-recenter (not no-recenter))
(recenter))))
(defun diff-hl-previous-hunk ()
@@ -1104,7 +1104,7 @@ its end position."
((setq o (diff-hl-search-next-hunk t))
(goto-char (overlay-start o)))
(t
- (diff-hl-next-hunk)))))
+ (diff-hl-next-hunk nil t)))))
(defun diff-hl-mark-hunk ()
(interactive)EDIT: Would also want to update |
Hello. This PR adds a new variable
diff-hl-next-previous-hunk-auto-recenter, that when set causesdiff-hl-next-hunkanddiff-hl-previous-hunkto automatically callrecenterafter moving the point.In my configuration I use after advice on these functions to do this auto-recentering, but I thought it would be nicer if there was a diff-hl variable for this behavior.
Let me know if you think this is a good idea, and if there is anything you would like changed in this PR. Thanks!